<include file="Public/min-header" />
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
	<style type="text/css">
		th{text-align: center;background: #eee;}
	</style>
    <include file="Public/breadcrumb"/> 
	<section class="content">
       <div class="row">
       		<div class="col-xs-12">
	       		<div class="box">
	             <div class="box-header">
	             <div class="row">
  					<div class="col-md-10" style="width: 100%;">
						<div class="navbar navbar-default">
						        <form action="" id="search-form2" class="navbar-form form-inline" method="get">
						                                <div class="form-group">
						                                    <div class="input-group">
						                                        <input type="text" name="consignee" id="consignee" placeholder="客户/客户店铺" id="input-member-id" class="input-sm form-control" style="width:150px;" value="{:I('consignee')}">
						                                    </div>
						                                </div>
						                                <div class="form-group">
						                                    <div class="input-group">
						                                        <input type="text" name="order_sn" id="order_sn" placeholder="订单号搜索" id="input-order-id" class="input-sm form-control" style="width:150px;" value="{:I('order_sn')}">
						                                    </div>
						                                </div>
						                                <div class="form-group">
						                                    <div class="input-group" style="width: 300px;margin-left: 15px;">
						                                      <div class="input-group-addon" style="width:35%;">
						                                       		选择时间  <i class="fa fa-calendar"></i>
						                                      </div>
						                                      <input type="text" class="form-control" name="timegap" value="{:I('timegap')}" id="start_time" autocomplete="off" style="width:250px;">
						                                      </div>
						                                </div>
														<div class="form-group">
															<select name="type" id="type" class="input-sm" style="width:100px;">
																<if condition="$vo['type'] eq '0'">
																	<?php
																	 if(I("type")=="0"){
																						?>
																	<option value="">类型</option>
																	<option value="0" selected="selected">维修</option>
																	<option value="1">换货</option>
																	<?php
																					}elseif(I("type")=="1"){
																					?>
																	<option value="">类型</option>
																	<option value="0">维修</option>
																	<option value="1"  selected="selected">换货</option>
																	<?php
																					}else{
																					?>
																	<option value="">类型</option>
																	<option value="0">维修</option>
																	<option value="1">换货</option>
																	<?php
																					}
																					?>
															</select>
														</div>

														<div class="form-group">
															<select name="status" id="status" class="input-sm" style="width:100px;">
																<if condition="$vo['status'] eq '0'">
																	<?php
																	 if(I("status")=="0"){
																						?>
																	<option value="">状态</option>
																	<option value="0" selected="selected">进行中</option>
																	<option value="1">已完成</option>
																	<?php
																					}elseif(I("status")=="1"){
																					?>
																	<option value="">状态</option>
																	<option value="0">进行中</option>
																	<option value="1"  selected="selected">已完成</option>
																	<?php
																					}else{
																					?>
																	<option value="">状态</option>
																	<option value="0">进行中</option>
																	<option value="1">已完成</option>
																	<?php
																					}
																					?>
															</select>
														</div>

														<div class="form-group">
															<input class="btn btn-primary margin" type="submit" value="确定">
														</div>
														<?php if($percentag == 1){ ?>
														<button type="button" class="btn btn-info pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
														<?php }?>
						                            </form>
						                    </div>
                 	</div>
		  		 </div>
	             </div><!-- /.box-header -->
	             <div class="box-body" style="margin-top: -30px;">
	           	 <div class="row">
	            	<div class="col-sm-12">
		              <table id="list-table" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
		                 <thead>
		                   <tr role="row">
                               <th class="sorting" align="center">单号/备注</th>
							   <th class="sorting" align="center">买家</th>
			                   <th class="sorting" align="center">产品名称</th>
			                   <th class="sorting" align="center">单价</th>
			                   <th class="sorting" align="center">数量</th>
							   <th class="sorting" align="center">创建时间</th>
							   <th class="sorting" align="center">状态</th>
							   <th class="sorting" align="center">完成时间</th>
							   <th class="sorting" align="center">关联订单</th>
							   <th class="sorting" align="center">是否先补货</th>
							   <th class="sorting" align="center">领取状态</th>
							   <th class="sorting" align="center">操作</th>
		                   </tr>
		                 </thead>
						<tbody>
							<?php
							$heji_ptprices=0;
							?>
                         <foreach name="orderList" item="vo" key="k" >
                          <tr role="row" align="center">
                             <td><a href="javascript:" id="chakan" rel="{$vo.order_id}">{$vo.order_sn}</a>/{$vo.remark}</td>
							 <td>{$vo.company}</td>
                             <td>{$vo.goods_name}({$vo.key_name})</td>
							 <td>{$vo.member_goods_price}</td>
							 <td>{$vo.goods_num}</td>
		                     <td>{$vo.addtime|date='Y-m-d H:i',###}</td>
							  <td>
								  <if condition="$vo['status'] eq '1'">
									  <if condition="$vo['type'] eq '0'">
										  <span style="color: green">已维修</span>
										  <else/>
										  <span style="color: green">已换货</span>
									  </if>
									  <else/>
									  <if condition="$vo['type'] eq '0'">
										  <span style="color: red">维修中</span>
										  <else/>
										  <span style="color: red">换货中</span>
									  </if>
								  </if>
							  </td>
							  <td>{$vo.status_time}</td>
							  <td>{$vo.fix_sn}</td>
							   <td>
								  <if condition="$vo['is_exchange'] eq '0'">
									  <span style="color: red">不先补货</span>
									  <else/>
									  <span style="color: green">先补货</span>
								  </if>
							  </td>
							  <td>
								  <if condition="$vo['is_receive'] eq '0'">
									  <span style="color: red">未领取</span>
									  <else/>
									  <span style="color: green">已领取</span>
								  </if>
							  </td>
							 
							  <td>
								 <if condition="$vo.status neq 1 && $vo.is_receive eq 1 && $vo.fix_sn eq '' ">
									 <a href="JavaScript:;" id="fix_finish" rel="{$vo.id}" res="{$vo.type}" rev="{$vo.order_id}" class="btn btn-info" data-toggle="tooltip" >操作完成</a>
									 <elseif condition="$vo.status neq 1 && $vo.is_exchange eq 1 && $vo.fix_sn eq '' " />
									 <a href="JavaScript:;" id="fix_finish" rel="{$vo.id}" res="{$vo.type}" rev="{$vo.order_id}" class="btn btn-info" data-toggle="tooltip" >操作完成</a>
									 <elseif condition="$vo.status eq 1 && $vo.is_receive eq 1 && $vo.fix_sn" />
									 <span style="color: green">已完成</span>
									 <else/>
									 <span></span>
								 </if>
							 </td>
						  </tr>
		                  </foreach>

		                   </tbody>
		                 <tfoot>
		                 </tfoot>
		               </table>
	               </div>
	          </div>
              <div class="row">
              	    <div class="col-sm-6 text-left"></div>
                    <div class="col-sm-6 text-right">{$page}</div>		
              </div>
	          </div>
	        </div>
       	</div>
       </div>
   </section>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$('#start_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
	        showWeekNumbers: true,
	        timePicker: true,
	        timePickerIncrement: 1,
	        timePicker12Hour: false,
	        opens: 'right',
	        buttonClasses: ['btn btn-default'],
	        applyClass: 'btn-small btn-primary',
	        cancelClass: 'btn-small',
		    locale : {
	            applyLabel : '确定',
	            cancelLabel : '取消',
	            fromLabel : '起始时间',
	            toLabel : '结束时间',
	            customRangeLabel : '自定义',
	            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
	            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
	            firstDay : 1
	        }
	});
	$("#list-table #chakan").click(function(){
			var myrel=$(this).attr('rel');
			var myrul='/index.php/seller/order/detail/order_id/'+myrel;//+myrel;
				layer.open({
				  type: 2,
				  title:'订单信息',
				  shadeClose: true, //点击遮罩关闭
				  skin: 'layui-layer-rim', //加上边框
				  area: ['920px', '620px'], //宽高
				  content: myrul
			})
	    });
		$("#daochu").click(function(){
			var order_sn=$("#order_sn").val();
			var consignee=$("#consignee").val();
			var timegap=$("#start_time").val(); 
			var order_status=$("#status").val();
			var type=$("#type").val();

			location.href="/index.php/Seller/order/export_fix?order_sn="+order_sn+"&consignee="+consignee+"&timegap="+timegap+"&status="+order_status+"&type="+type;
		})


	$("#list-table #fix_finish").click(function(){
		var id=$(this).attr('rel');
		var order_id=$(this).attr('rev');
		var type=$(this).attr('res');
		var type_string = type == 1 ? "换货" : "维修";
		layer.confirm('您确定要完成这个'+type_string+'单吗？', {
			btn: ['确定','取消'] //按钮
		}, function(){
			layer.prompt({
				value: '0',
				title: '是否需要收取'+type_string+'费用，直接输入金额，免费填0即可'
			},function(value, index, elem){
				layer.load();
				$.post("/index.php/seller/order/fix_finish",
						{
							id:id,
							order_id:order_id,
							price:value
						},
						function(data,status){
							layer.closeAll('loading');
							data=JSON.parse(data);
							if(data.code=='200'){
								layer.msg(data.msg, {icon:6});
								location.reload();
							}else{
								layer.msg(data.msg, {icon:5});
							}
						});


			});


		});
	})
});
</script>
</body>
</html>